# -*- coding:utf-8 -*-

# @Time : 2022/11/22 15:11
# @Author : 快乐的小猴子
# @Version : 
# @Function : 

import requests
from lxml import etree

while True:
    num = input('第n页电影排行榜信息(1-10)(q/Q退出)：')
    if num.strip().upper() == 'Q':
        break
    url = 'https://movie.douban.com/top250?start='+str(25*int(num))+'&filter='
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36'
    }

    resp = requests.get(url=url, headers=headers, )
    resp.encoding = 'utf-8'
    et = etree.HTML(resp.text)
    movie_name = et.xpath('//div[@class="article"]/ol/li/div/div[@class="info"]/div[1]/a/span[1]/text()')
    movie_score = et.xpath('//div[@class="article"]/ol/li/div/div[@class="info"]/div[2]/div[@class="star"]/span[2]/text()')
    movie_pl_cnt = et.xpath('//div[@class="article"]/ol/li/div/div[@class="info"]/div[2]/div[@class="star"]/span[4]/text()')

    for x in range(0, len(movie_name)):
        print(x+1, movie_name[x], movie_score[x], movie_pl_cnt[x])